<?php

use Illuminate\Database\Seeder;
use App\Role;
use App\Permission;
use App\User;

class RoleSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //
        $User = ['email'=>'admin@qq.com','name'=>'admin','password'=>bcrypt('123456')];
        $Test = ['email'=>'test@qq.com','name'=>'test','password'=>bcrypt('123456')];
        //创建用户
        $user = User::create($User);
        $test = User::create($Test);

        //创建角色
        $testRole = Role::create([
            'name'=>'普通管理员',
            'display_name'=>'user',
            'description'=>'普通管理员',
        ]);
        //创建角色
        $adminRole = Role::create([
            'name'=>'超级管理员',
            'display_name'=>'admin',
            'description'=>'超级管理员',
        ]);

        //把角色付给用户
        $user -> attachRole($adminRole);
        $test -> attachRole($testRole);

    }
}
